﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using GandAInvitaciones.BusinessEntity;
using GandAInvitaciones.DAO;

namespace GandAInvitaciones.BusinessComponent
{
    public class CommonService
    {
        public static void InsertaContacto(Contacto obj)
        {
            CommonServiceDAO.InsertaContacto(obj);
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("mail.ganda-invitaciones.com");
            mail.From = new MailAddress("site@ganda-invitaciones.com", "ganda-invitaciones.com", Encoding.UTF8);
            mail.Subject = "Contacto:" + obj.Nombre;
            mail.Body = "Telefono: " + obj.Telefono + "<br/>" + "Correo: " + obj.Correo + "<br/>" +
                        "Asunto: <br/>" + obj.Asunto.Replace("\n", "<br/>");
            mail.IsBodyHtml = true;
            mail.To.Add("ventas@ganda-invitaciones.com");
            SmtpServer.Port = 26;
            SmtpServer.Credentials = new System.Net.NetworkCredential("site@ganda-invitaciones.com", "822862");
            ////SmtpServer.EnableSsl = true;
            SmtpServer.Send(mail);
        }

        public static void InsertaVisita(Visita obj)
        {
            CommonServiceDAO.InsertaVisita(obj);
        }

        public static void InsertaBoletin(Boletin obj)
        {
            CommonServiceDAO.InsertaBoletin(obj);
        }

        public static Cupon InsertaCuponGenerado(Cupon obj)
        {
            return CommonServiceDAO.InsertaCuponGenerado(obj);
        }

        public static string UtilizaCupon(Cupon obj)
        {
            return CommonServiceDAO.Utilizacupon(obj);
        }
    }
}
